namespace Oplug.EntityFramework.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitDB : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.DataCode",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        CodeKey = c.String(maxLength: 20),
                        CodeValue = c.String(maxLength: 50),
                        Layout = c.String(maxLength: 8),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.DataSQL",
                c => new
                    {
                        ID = c.Long(nullable: false, identity: true),
                        ViewName = c.String(nullable: false, maxLength: 50),
                        DisplayName = c.String(nullable: false, maxLength: 50),
                        Memo = c.String(maxLength: 200),
                        ViewType = c.String(maxLength: 8),
                        CreateTime = c.DateTime(nullable: false),
                        CreateUser = c.String(maxLength: 20),
                        SQLText = c.String(nullable: false),
                        Version = c.String(maxLength: 10),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Departments",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        DepartName = c.String(maxLength: 50),
                        DepartCode = c.String(maxLength: 10),
                        Powers = c.String(),
                        Leader = c.String(maxLength: 50),
                        ParentId = c.Int(nullable: false),
                        Persons = c.Int(nullable: false),
                        Depth = c.Int(nullable: false),
                        Intro = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Employee",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        EmpID = c.String(nullable: false, maxLength: 50),
                        EmpName = c.String(maxLength: 50),
                        DeptName = c.String(maxLength: 50),
                        UserName = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.FormMethods",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        FormName = c.String(maxLength: 50),
                        MethodName = c.String(maxLength: 50),
                        MethodType = c.String(maxLength: 50),
                        MethodDesc = c.String(maxLength: 50),
                        AllowUsers = c.String(),
                        DenyUsers = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.RossConfig",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Units = c.String(storeType: "ntext"),
                        Departs = c.String(storeType: "ntext"),
                        Reasons = c.String(storeType: "ntext"),
                        TerminalNum = c.Int(nullable: false),
                        Company = c.String(maxLength: 50),
                        Telphone = c.String(maxLength: 20),
                        Zipcode = c.String(maxLength: 20),
                        Address = c.String(maxLength: 50),
                        Fax = c.String(maxLength: 20),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.RossPowers",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        PowerIndex = c.String(maxLength: 50),
                        PowerName = c.String(maxLength: 50),
                        InActive = c.Boolean(nullable: false),
                        ParentID = c.Int(nullable: false),
                        Depth = c.Int(nullable: false),
                        Client = c.String(maxLength: 50),
                        Icon = c.String(maxLength: 50),
                        OrderNo = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.RossUsers",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        UserID = c.String(maxLength: 10),
                        UserName = c.String(maxLength: 20),
                        Password = c.String(maxLength: 20),
                        EmpID = c.String(maxLength: 20),
                        LastLoginTime = c.DateTime(),
                        LastLoginIP = c.String(),
                        LastLoginClient = c.String(),
                        LastLoginOS = c.String(),
                        Powers = c.String(),
                        DepartCode = c.String(maxLength: 10),
                        ClassCode = c.String(maxLength: 20),
                        GroupCode = c.String(maxLength: 20),
                        FieldRossProj = c.String(storeType: "ntext"),
                        FieldRossLive = c.String(storeType: "ntext"),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Tasks",
                c => new
                    {
                        ID = c.Long(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 50),
                        Contents = c.String(),
                        Status = c.String(maxLength: 4),
                        CreateTime = c.DateTime(nullable: false),
                        EndTime = c.DateTime(),
                        CompleteTime = c.DateTime(),
                        IsMilepost = c.Boolean(nullable: false),
                        IsComplete = c.Boolean(nullable: false),
                        LeaderId = c.Int(nullable: false),
                        UserId = c.Int(nullable: false),
                        ParentId = c.Int(nullable: false),
                        EmgGrade = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.UpdateLogs",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        LogTitle = c.String(maxLength: 50),
                        PartNums = c.String(storeType: "ntext"),
                        ErrorLog = c.String(storeType: "ntext"),
                        CompleteLog = c.String(storeType: "ntext"),
                        Status = c.String(maxLength: 8),
                        SysTime = c.DateTime(),
                        UserName = c.String(maxLength: 50),
                        MachineName = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.ID);
            
        }
        
        public override void Down()
        {
            DropTable("dbo.UpdateLogs");
            DropTable("dbo.Tasks");
            DropTable("dbo.RossUsers");
            DropTable("dbo.RossPowers");
            DropTable("dbo.RossConfig");
            DropTable("dbo.FormMethods");
            DropTable("dbo.Employee");
            DropTable("dbo.Departments");
            DropTable("dbo.DataSQL");
            DropTable("dbo.DataCode");
        }
    }
}
